<extend name="./base" />
<block name="pageContent">
    <style>
        .row {
            margin-left: 0;
            margin-right: 0;
        }

        .heard-tit {
            width: 20%;
            float: left;
            padding-left: 2%;
        }

        .heard-tit--pad {
            padding-left: 5%;
        }

        .not-padding {
            padding: 15px 0;
        }

        .hd-not-padding {
            padding: 0;
        }

        .seat {
            width: 40px;
            height: 24px;
        }

        .seat-name {
            width: 160px;
            height: 24px;
        }

        .width10 {
            width: 10%;
        }

        .heard-tit span {
            display: inline-block;
            margin-right: 20px;
        }

        .heard-tit .type-edits {
            color: #7488b0
        }

        .s_fh-tabhead .margin-left-4 {
            margin-right: 3%;
        }

        .padding-left-5 {
            padding-left: 5.4%;
        }
    </style>
    <div class="main-content">
        <!-- 头部面包屑导航条 -->
        <div class="breadcrumbs" id="breadcrumbs">
            <!--导航路径列表-->
            <ul class="breadcrumb no-margin-left">
                <li>
                    <a>管理后台</a>
                </li>
                <li class="action">
                    新闻管理
                </li>
            </ul>
        </div>
        <!--页面容器-->
        <div class="page-content">
            <div class="nav-tab" style="position: relative">
                <ul class="nav-tab-title ">
                    <li class="nav-this">分类列表</li>
                </ul>
            </div>
            <div class="row">
                <!-- 分红记录-->
                <div class="row ">
                    <div class="col-xs-12">
                        <form class="form-horizontal s_input-bgcolor">
                            <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12 pad-b20">
                                <div class="form-group">
                                    <label class="col-sm-3 control-label text-right no-padding-right"
                                           for="form-field-1-0">分类名称： </label>
                                    <div class="col-sm-8">
                                        <input type="text" id="form-field-1-0" placeholder="请输入分类名称"
                                               class="form-control">
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-9 col-md-6 col-sm-12 col-xs-12 pad-b20 text-right">
                                <a href="{$Think.config.DOMAIN_URL}/course/addType" class="btn " style="width: 120px;    border-radius: 2rem; background: #36c724!important;border-color: #36c724;margin-left: 20px;">新增</a>
                                <button class="btn" style="width:120px;border-radius:2rem;background:#fba40a!important;border-color: #fba40a;margin-left: 20px;margin: 0 0 10px;"> 查询</button>
                            </div>
                        </form>
                        <div class="space"></div>
                        <div style="padding: 0 20px;clear: both;">
                            <div class="row s_fh-headbg font-size16">
                                <div class="heard-tit ">&nbsp;</div>
                                <div class="heard-tit ">名称</div>
                                <div class="heard-tit ">排序</div>
                                <div class="heard-tit ">操作</div>
                            </div>
                            <!-- /.row -->
                            <volist  name="resList" id="vo">
                                <div class="row s_fhtable">
                                    <header class="s_fh-tabhead not-padding  parents">
                                        <div class="heard-tit  ">
                                            <img src="/Public/AdminTpl/img/unfold_icon.png" alt="" class="open"/>
                                        </div>
                                        <div class="heard-tit ">
                                            {$vo.name}
                                        </div>
                                        <div class="heard-tit ">
                                            <input type="text" value="{$vo.sort}" onblur="editSort(this,{$vo.id})" class="seat">
                                        </div>
                                        <div class="heard-tit ">
                                            <span class="type-edits" onclick="locationTo('{$Think.config.DOMAIN_URL}/course/editType?id={$vo.id}&page={$page}')">编辑</span>
                                            <span class="color-red" onclick="delMg({$vo.id})">删除</span>
                                        </div>
                                    </header>
                                    <div class="row s_fh-showhide child" style="display: none">
                                        <volist name="childRes[$vo[id]]" id="cvo">
                                            <div class="child">
                                                <div class="s_fh-tabhead not-padding border-top">
                                                    <div class="heard-tit " style="height: 1px;"></div>
                                                    <div class="heard-tit  padding-left-5">
                                                        {$cvo.name}
                                                    </div>
                                                    <div class="heard-tit ">
                                                        <input type="text" value="{$cvo.sort}" onblur="editSort(this,{$cvo.id})" class="seat">
                                                    </div>
                                                    <div class="heard-tit ">
                                                        <span class="type-edits" onclick="locationTo('{$Think.config.DOMAIN_URL}/course/editType?id={$cvo.id}&page={$page}')">编辑</span>
                                                        <span class="color-red" onclick="delMg({$cvo.id})">删除</span>
                                                    </div>
                                                </div>
                                            </div>
                                        </volist>
                                    </div>
                                </div>
                            </volist>
                        </div>
                    </div>
                </div>
            </div>
            <div class="text-center">
                {$pageShow}
            </div>
        </div>
    </div>

    <script>
        //删除
        function delMg(id){
            $.popup({
                type: 1,
                content: "确定要删除吗？",
                cls:'fa-trash-o',
                callback: function () {
                    $.popup.proto.close();
                    location.href = '/course/delType?id='+id+'&page='+{$page};
                }
            });
        }
        //改变排序
        function editSort(that,id){
            $.ajax({
                type:"post",
                dataType:"json",
                url:"/course/editSort",
                data:{
                    id: id,
                    sort: $(that).val()
                },
                success:function(data){
                    if(data.code == 0){
                        layer.msg('操作成功', {icon: 6,time: 1000});
                    }
                }
            });
        }

        $(".parents .open").on("click", function () {
            $(this).parents(".parents").siblings(".child").toggle();
        })
    </script>
</block>